package com.jinmdz.fmis.mapper.mapper;

import com.jinmdz.fmis.mapper.entity.FuneralBusinessLogEntity;
import com.jinmdz.fmis.mapper.mapper.provider.FuneralBusinessLogProvider;
import org.apache.ibatis.annotations.*;

import java.util.ArrayList;

/**
 * 殡葬业务日志表Mapper
 *
 * @author generator
 * @date 2020-03-12 17:08
 */
public interface FuneralBusinessLogMapper {

    /**
     * 增加FuneralBusinessLog
     *
     * @param entity 数据实体
     * @return
     * @author generator
     * @date 2020-03-12 17:08
     */
    @InsertProvider(type = FuneralBusinessLogProvider.class, method = "insertFuneralBusinessLog")
    @Options(useGeneratedKeys = true, keyProperty = "entity.id", keyColumn = "id")
    void insertFuneralBusinessLog(@Param("entity") FuneralBusinessLogEntity entity);

    /**
     * 删除FuneralBusinessLog
     *
     * @param id             主键
     * @param modifiedUserId 修改用户外键
     * @param version        版本号
     * @return
     * @author generator
     * @date 2020-03-12 17:08
     */
    @Update(" update funeral_business_log set deleted = 1,modified_user_id = #{modifiedUserId},version = unix_timestamp(now()) where id = #{id} and version = #{version} and unmodified = 0 and deleted = 0 ")
    void deletedForFuneralBusinessLog(@Param("id") Integer id, @Param("modifiedUserId") Integer modifiedUserId, @Param("version") Long version);

    /**
     * 修改FuneralBusinessLog
     *
     * @param entity 数据实体
     * @return
     * @author generator
     * @date 2020-03-12 17:08
     */
    @UpdateProvider(type = FuneralBusinessLogProvider.class, method = "updateFuneralBusinessLog")
    void updateFuneralBusinessLog(@Param("entity") FuneralBusinessLogEntity entity);

    /**
     * 查询FuneralBusinessLog实体
     *
     * @param id 主键
     * @return FuneralBusinessLogEntity
     * @author generator
     * @date 2020-03-12 17:08
     */
    @Select(" select id,deleted,business_code,business_type_code,business_type,business_describe,remark,create_user_name,funeral_parlour_code,create_user_id,gmt_create,unmodified,modified_user_id,gmt_modified,version from funeral_business_log where id = #{id} and deleted = 0 limit 1 ")
    FuneralBusinessLogEntity getFuneralBusinessLogById(@Param("id") Integer id);

    /**
     * 查询FuneralBusinessLog列表
     *
     * @param entity 数据实体
     * @return FuneralBusinessLogEntity
     * @author generator
     * @date 2020-03-12 17:08
     */
    @SelectProvider(type = FuneralBusinessLogProvider.class, method = "listFuneralBusinessLog")
    ArrayList<FuneralBusinessLogEntity> listFuneralBusinessLog(@Param("entity") FuneralBusinessLogEntity entity);
}